﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace PNut_Project_Lin
{
    public partial class ServiceCar : PhoneApplicationPage
    {

        List<checkCar> listServiceCar = new List<checkCar>();


        public ServiceCar()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(ServiceCar_Loaded);
        }

        void ServiceCar_Loaded(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();

            stbt.Visibility = System.Windows.Visibility.Collapsed;

            listServiceCar.Add(new checkCar("นิสสัน", "022057778", "", "", "http://www.nissan.co.th/th/Aftersales/Twenty-four-hour-roadside-assistance.aspx"));
            listServiceCar.Add(new checkCar("โตโยต้า", "1800238444", "", "", "http://www.toyota.co.th/customerservice/"));
            listServiceCar.Add(new checkCar("ฮอนด้า", "023058444", "", "", "http://www.honda.co.th/owner/"));
            listServiceCar.Add(new checkCar("มิตซูบิชิ", "025299500", "", "", "http://www.mitsubishi-motors.co.th/th/After-Sales"));
            listServiceCar.Add(new checkCar("เชฟโรเลต", "1734", "", "", "http://www.chevrolet.co.th/owners/After-Sales-Service.html"));

            ServiceCarListBox.DataContext = listServiceCar;

        }

        private void web_bt_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();
            task.URL = listServiceCar.ElementAt(ServiceCarListBox.SelectedIndex).Link;
            task.Show();
        }

        private void tel_bt_Click(object sender, RoutedEventArgs e)
        {
            PhoneCallTask task = new PhoneCallTask();
            task.PhoneNumber = listServiceCar.ElementAt(ServiceCarListBox.SelectedIndex).Detail;
            task.DisplayName = listServiceCar.ElementAt(ServiceCarListBox.SelectedIndex).Name;
            task.Show();
        }

        private void ServiceCarListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ServiceCarListBox.SelectedIndex != -1)
            {
                stbt.Visibility = System.Windows.Visibility.Visible;
            }

        }
    }
}